<script setup>
import { onMounted, ref } from 'vue'
import { doGet } from '@/http/httpRequest';

let userList = ref([])

function getData() {
  doGet('/api/user', {})
    .then(resp => {
      console.log(resp)
      userList.value = resp.data.data
    })
    .catch(err => {

    })
    .finally(() => {

    })
}

// 挂载后执行
onMounted(() => {
  getData()
})


</script>

<template>
  <el-table :data="userList" style="width: 100%">
    <el-table-column type="index" label="序号" width="180" />
    <el-table-column prop="nickname" label="姓名" width="180" />
    <el-table-column prop="phone" label="手机号" width="180" />
    <el-table-column prop="email" label="邮箱" width="180" />
    <!-- 插槽 -->
    <el-table-column prop="sex" label="性别">
      <template #default="scope">
        {{ scope.row.sex == 1 ? '男' : '女' }}
      </template>
    </el-table-column>
    <el-table-column prop="address" label="地址" />
    <el-table-column prop="createTime" label="创建时间" />
    <el-table-column label="操作">
      <template #default="scope">
        <a :href="`/user/edit/${scope.row.id}`">编辑</a>
        <el-button type="danger" size="mini">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
